<div class="tabbable tabs-left">
              <ul class="nav nav-tabs">
              	<li><h5><?php echo $this->translate('管理员组信息'); ?></h5></li>
                <li class="active"><a data-toggle="tab" href="#user_a"><?php echo $this->translate('基本信息'); ?></a></li>
                <li><a data-toggle="tab" href="#user_b"><?php echo $this->translate('权限设置'); ?></a></li>
              </ul>
              <form class="form-horizontal" name="user_group_form" id="user_group_form" method="post" action="<?php if($this->admin_group_info) echo $this->url('adminetutor/default/admin_group_id',array('action'=>'editgroup','controller'=>'admin','admin_group_id'=>$this->admin_group_info->admin_group_id)); else echo ''; ?>">
              <input type="hidden" name="group_id" id="group_id" value="<?php if($this->admin_group_info) echo $this->admin_group_info->admin_group_id; else echo ''; ?>" />
              <div class="tab-content">
    			<div id="sticky_navigation" style="height:30px;border-bottom:4px solid #DFDFDF;">
        			<div class="pull-left" style="font-size:16px;line-height:30px;"><strong><?php if($this->admin_group_info) echo $this->translate('编辑'); else echo $this->translate('新加'); ?><?php echo $this->translate('管理员组'); ?></strong></div>
        			<div class="pull-right">
                	<a href="<?php echo $this->url('adminetutor/default',array('action'=>'admingroup','controller'=>'admin')); ?>" class="btn btn-small"><i class="icon-arrow-left"></i> <?php echo $this->translate('返回管理员组列表'); ?></a>&nbsp;
                	<a href="<?php echo $this->serverUrl(true); ?>" class="btn btn-small btn-warning"><i class="icon-repeat icon-white"></i> <?php echo $this->translate('刷新'); ?></a>&nbsp;
                    <?php if($this->admin_group_info) { ?>
                    <a href="javascript:;" onclick="return group_del_js(<?php echo $this->admin_group_info->admin_group_id ?>);" class="btn btn-small btn-danger"><i class="icon-remove icon-white"></i> <?php echo $this->translate('删除管理员组'); ?></a>&nbsp;
                    <?php } ?>
                	<button type="submit" class="btn btn-small btn-primary"><i class="icon-ok icon-white"></i> <?php echo $this->translate('保存管理员组信息'); ?></button>&nbsp;
                	<a href="<?php echo $this->myviewalias()->dbshopHelpUrl('admin_group_set'); ?>" target="_blank" class="btn btn-small btn-info"><i class="icon-info-sign icon-white"></i> <?php echo $this->translate('查看帮助说明'); ?></a>
                	</div>
        		</div>
                <div id="user_a" class="tab-pane active">
                	<div class="well admin_add_header_well"><?php echo $this->translate('基本信息'); ?></div>
                	<div class="well admin_add_well"> 
                    	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('管理员组名称'); ?><span class="must_add_value">*</span>：</label>
           					<div class="controls">
              					<input type="text" id="admin_group_name"  name="admin_group_name" class="span6" value="<?php echo ($this->admin_group_info ? $this->escapeHtml($this->admin_group_info->admin_group_name) : ''); ?>">
            				</div>                        
                        </div>
                                                                                                                       
                  	</div>
                </div>
                
				<div id="user_b" class="tab-pane">
                	<div class="well admin_add_header_well"><?php echo $this->translate('权限设置'); ?></div>
                	<div class="well admin_add_well">
                    <?php if (isset($this->admin_group_info) and $this->admin_group_info->admin_group_id == 1) { ?>
                    	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('权限设置'); ?>：</label>
           					<div class="controls">
              					<label class="checkbox inline"><input type="checkbox" disabled="disabled" checked="checked" name="purview[purviewAll]" value="1" /><?php echo $this->translate('全部权限'); ?></label>
            				</div>                        
                        </div>                    
                    <?php } else { foreach($this->purview as $purview_key => $purview_value) { ?>
                    	<div class="control-group">
                  			<label for="input01" class="control-label"><strong><?php echo $this->purview_lang[$purview_key]; ?></strong></label>
           					<div class="controls">
								<?php $key_content = key($purview_value); ?>
								<label class="checkbox inline"><input type="checkbox" class="dbshop-group" id="<?php echo $key_content; ?>"><?php echo $this->translate('全选'); ?></label>
							</div>
                        </div>
                            	<?php foreach($purview_value as $p_key => $p_val) { ?>
                    	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->purview_lang[$p_key]; ?>：</label>
           					<div class="controls">	
								<?php foreach($p_val as $value) { $pur_str = $purview_key . '|' . $p_key . '|' . $value; ?>
                                	<label class="checkbox inline"><input type="checkbox" class="<?php echo $key_content; ?>" onclick="onclick_select('<?php echo $key_content; ?>');" name="purview[<?php echo $pur_str; ?>]" value="1" <?php if(isset($this->checked_purview[$pur_str]) and $this->checked_purview[$pur_str] == 1) echo 'checked="checked"'; ?> /><?php echo $this->purview_lang[$p_key . $value]; ?></label>
                                	<?php } ?>
            					</div>
                        	</div>                                
                            <?php } } } ?>
                  	</div>
                </div>
                
             </div>
              </form>
</div>
<script>

$(document).ready(function() {
	$("#user_group_form").validate({
		rules: {
			admin_group_name: {
				required: true,
				maxlength:60
			}
		},
		messages: {
			admin_group_name: {
				required: "<?php echo $this->translate('请输入管理员组名称！'); ?>",
				maxlength:"<?php echo $this->translate('管理员组名称最长为60个汉字！'); ?>"
			}
		}
	});
});

//全选
$(".dbshop-group").each(function(){
	$(this).on("click",function(){
		var id = $(this).attr('id');
		var checked = !!$(this).attr("checked");
		$("."+id).attr('checked',checked);
	})
});
//编辑时，全选状态
$(".dbshop-group").each(function(){
	var id = $(this).attr('id');
	var checkstate = true;
	$("."+id).each(function(){
		var checked = !!$(this).attr("checked");
		if(!checked){
			checkstate = false;
			return;
		}
	});
	$(this).attr('checked', checkstate);
});

//选择一个权限时，判断是否已经全选
function onclick_select(idStr) {
    var id = $('#'+idStr).attr('id');
    var checkstate = true;
    $("."+id).each(function(){
        var checked = !!$(this).attr("checked");
        if(!checked){
            checkstate = false;
        }
    });
    $('#'+idStr).attr('checked', checkstate);
}

//客户组删除js
function group_del_js(admin_group_id) {
	if(window.confirm('<?php echo $this->translate('您确实要删除该管理员组吗？'); ?>')) {
	$.post("<?php echo $this->url('adminetutor/default',array('action'=>'groupdel','controller'=>'admin')); ?>",{admin_group_id:admin_group_id},
	function(data){
		if(data != 'false') {
			window.location.href='<?php echo $this->url('adminetutor/default',array('action'=>'admingroup','controller'=>'admin')); ?>';
			return true;
		} else {
			alert('<?php echo $this->translate('管理员组删除失败，该管理员组下已经有管理员存在，需要先删除组下管理员信息！'); ?>');
		}
	});
	}
	return false;
}
</script>